<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>
 <head>
    <title>生产建议单</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>

		<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
    	<script type="text/javascript" src="${ctx}/js/jsp/yd/logic/prosuggest.js"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/yd/logic/prosuggest";
		var basic_WUrl="yd/logic/prosuggest";
		var basic_Title="生产建议单管理";
		var show_Width=950;
		var show_Hight=400;
		function createSearch(){
			init(1,6,'140,140,140,140,140,140','18%');
			//第一行的数据
			addCommon(0,0,"lable","单据编号");
			addCommon(0,1,"txtlike","no");
			addCommon(0,2,"lable","来源单据号");
			addCommon(0,3,"txtlike","source_bill_no");
			addCommon(0,4,"lable","处理状态：");
			addCommon(0,5,"selectEnum","bill_status","<option></option><option value='1'>未处理</option>"+
					"<option value='2'>已处理</option>");
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}

		
		function tbDealCheck(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			if (rows==null || 0== rows.length){
				$.dialog.alert('请选择待处理的行！');
				return;
			}
			var canDeal = true;
			$(rows).each(function() {
				if (!(this.billStatus==1)){
					canDeal = false;
					$.dialog.alert('待处理的单据中,存在已处理的单据状态！');
				}
				
			});
			
			if(canDeal){
				tbDeal();
			}
			
		}
		function tbDeal(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getCheckedRows(); 
			
			if (rows.length==0){
				$.dialog.alert('请选择待处理的记录');
				return;
			}
		    
		    var ids = "";
			for(var i = 0;i < rows.length ;i++) {
			 	if(i!=0){
			 		ids+=",";
			 	}
			 	//获得行数据
			 	ids += rows[i].id;					 	   
			}
			
			getDG().dialog({content: "请确定处理选择的数据!",width: 250,lock: true,max: false,min: false,
				title:'Confirm Infor',
				button: [
				         {
				             name: 'Yes',
				             callback: function(){
					            $.ajax({
					           	      url: basic_Url+"/deal.do",
					           	      global: false,
					           	      type: "POST",
					           	      dataType: "json",
					           	      data: ({ids : ids}),		     
					           	      success: function(msg){
					           	    	//manager.trigger("reloadGrid");
					           	    	searchAP();//重新加载查询
					           	    	$.dialog.alert(msg.infor);  
					           	    	
					           	      }
					           	   }
					           	);
				             }
				         },
				         {
				        	   name: 'No',
					           focus: true
				         }             
				     ]
			}).zindex();
			
		}
	</script>
  </head>
<body onload="createSearch()">
   <div id="layout1">
      <div position="top">
          <div class="panelBar">
	           <ul class="toolBar">
	             
		           <!-- 
		           <li><a class="add" onclick="add()"><span>添加</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
				    -->
				   <li><a class="edit" onclick="tbDealCheck()"><span>标记为处理</span></a></li>
				    
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
   </div>
 
</body>
</html>